<template>
  <div >
	  <body>
     <div  class="form-style-pri">
		 	<div id="printMe" v-html="nowHtml">
				
			 </div>
			  <button @click="submitReport">提交</button>
			   <div v-print="'#printMe'">打印</div>
     </div>
         <!-- <div v-print="'#printMe'">打印</div>
		  <button @click="submitData">提交</button>-->
	  </body>
  </div>
</template>

<script>

import $ from "jquery"
import checkPermission from '@/utils/permission'
import { parseTime } from '@/utils/index'
import { report ,addReport} from '@/api/loanManageInfo'

export default {
  name: 'HomeIndex',
  components: {
   
  },
  data(){
    return {
	  loading:true,
	  
	  name1:"",
	  custNum:'',
	  custName:'',
	  moneyUseMethod:null,
	  content:'',
	  nowHtml:"",
		form:{
			busiType:"授信后业务",
			custKind:"授信后客户",
			id:"560fb621075311eabddefe22af050d33"
		},

		subForm:{
			reportData:null,
            taskId:"560fb621075311eabddefe22af050d33"
		}
    }
  },
  created(){
	     report(this.form).then(res => {
			 this.nowHtml = res
			setTimeout(() => {
                this.loading = false
             }, 170)
          }).catch(err => {
            this.loading = false
           
          })
	

  },
  mounted(){
	  console.log($)
  },
  methods:{
	  parseTime,
     checkPermission,
     submitData(){
		 console.log('custNum', this.custNum)
		 console.log('custName', this.custName)
		  console.log('moneyUseMethod', this.moneyUseMethod)
		 this.content =document.getElementById('sharehoder').innerHTML
		 console.log('content',this.content) 
		  
	 },
	 submitForm(){
		 console.log("提交")
	 },
	  submitReport(){
			var d= {}
			var t = $("#reportForm").serializeArray()
			console.log(t)
			t.forEach(item=>{
				d[item.name]=item.value
			})
			var tabData=[];
			
			$("#"+ "datalist-testList" +" tbody tr").each(function(trindex,tritem){
				var rowObj={};
				$(tritem).children("td").each(function(tdindex,tditem){
					var val=$(tditem).find("input").val();
					var key=$(tditem).find("input").attr("key");
					rowObj[key]=val;
				});
				tabData.push(rowObj);
			})
			console.log(d)
			console.log(tabData)

			 this.subForm.reportData = d;
			 

				addReport(this.subForm).then(res => {
						
						setTimeout(() => {
							this.loading = false
						}, 170)
				}).catch(err => {
				this.loading = false
			
			    })
		}
	 	
			
			
  }
} 
</script>

<style  scoped>
 
  
</style>